package org.aiforum.backend.service;

import java.util.List;

import javax.transaction.Transactional;
import javax.transaction.Transactional.TxType;

import org.aiforum.backend.common.QueryPreperty;
import org.aiforum.backend.common.Response;
import org.aiforum.backend.mapper.ContactMapper;
import org.aiforum.domain.Contact;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.util.StringUtil;

/**
 * 联系我们业务接口实现类
 * @author Administrator
 *
 */
@Service("contactService")
@Transactional(TxType.REQUIRED)
public class ContactServiceImpl  implements ContactService {
    
	@Autowired
	private ContactMapper contactMapper;//注入联系我们映射
	
	@Override
	public Contact find(int contactId) {
		Contact contact=contactMapper.findById(contactId);
		return contact;
	}

	@Override
	public Response delete(int contactId) {
		contactMapper.delete(contactId);
		Response response=Response.getInstaner();
		response.setState(true);
		response.setMessage("Delete Success");
		return response;
	}

	@Override
	public List<Contact> querys(QueryPreperty queryPreperty) {
		if(StringUtil.isNotEmpty(queryPreperty.getQueryValue().toString())){
			String value="%"+queryPreperty.getQueryValue()+"%";
			queryPreperty.setQueryValue(value);
		}else{
			queryPreperty.setQueryValue(null);
		}
		return contactMapper.querys(queryPreperty);
	}

}
